<?php
$path = '/var/www/wiisocial';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

require_once "data/dao/UserDAO.php";
require_once "services/FacebookProxy.php";
require_once "application/user/UserUtils.php";

/**
 * this script is executed daily as a cron job
 */

class UserInfoUpdater{
	
	
	/*
	 * update process
	 * 
	 * get all user ids
	 * get facebook info for user ids
	 * insert into user table
	 */
	public function update(){
		
		$udao = new UserDAO();
		$usersIds = $udao->getAllUsers();		

		$fb = new FacebookProxy();
		$fbInfo = $fb->getFacebookUserInfo($usersIds);
		
		foreach($fbInfo as $fb){
			
			if(UserUtils::userExists($fb['uid'])){
				$udao->updateUser($fb['uid'], $fb);
			}
		}
	}
}
$uiu = new UserInfoUpdater();
$uiu->update();
?>
